package com.example.appjetpackcompose

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import com.example.appjetpackcompose.databinding.ActivityTest4Binding

class TestActivity4 : AppCompatActivity() {

    lateinit var vb: ActivityTest4Binding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        vb= ActivityTest4Binding.inflate(layoutInflater)
        setContentView(vb.root)

        val extra:Int=intent.getIntExtra("extra",1)

        var fragment:Fragment?= supportFragmentManager.findFragmentById(vb.actTest4Content.id)
        if(fragment==null){
            when(extra){
                1 -> fragment=TestActivity4Fragment1.newInstance()
                2 -> fragment=TestActivity4Fragment2.newInstance()
                3 -> fragment=TestActivity4Fragment3.newInstance()
            }
            if (fragment != null) {
                ActivityUtilsKotlinExt.addFragmentToActivity(supportFragmentManager,fragment,vb.actTest4Content.id)
            }
        }
    }

}